
import area from "./area.json";

export class Area{
    // 全国区域
    static toArea(){
        let data = [];
        let len = area.length;
        for (let i = 0; i < len; i++) {
            let city = [];
            for (let j = 0, cityLen = area[i]['city'].length; j < cityLen; j++) {
                let _city = {};
                _city[area[i]['city'][j]['name']] = area[i]['city'][j]['area'];
                city.push(_city);
            }
            let _data = {};
            _data[area[i]['name']] = city;
            data.push(_data);
        }
        return data;
    }

    // 全国区域选择
    static toPicker(onPickerConfirm){
        return {
            pickerData: this.toArea(),
            pickerConfirmBtnText: "确定",
            pickerCancelBtnText: '关闭',
            pickerTitleText: '请选择',
            // selectedValue: ['广东', '深圳', '宝安'],
            // options={},
            onPickerConfirm,
            // onPickerCancel: pickedValue => {
            //     console.log("AreaCancel ", pickedValue);
            // },
            // onPickerSelect: pickedValue => {
            //     console.log("AreaSelect ", pickedValue);
            // }
        };
    }
}